class SmartTable():
    def __init__(self, mediator=None):
        self.mediator = mediator

    def work(self):
        print("展开餐桌并移动到餐厅指定位置")
        self.mediator.notify(self, 'work')

    def rest(self):
        print("折叠餐桌并回到指定储物位置")
        self.mediator.notify(self, 'rest')


class SmartChair():
    def __init__(self, number, mediator=None):
        self.number = number
        self.mediator = mediator

    def work(self):
        print(f"{self.number}号餐椅移动到餐厅指定位置")

    def rest(self):
        print(f"{self.number}号餐椅回到指定储物位置")

from abc import ABC

class Mediator(ABC):
    def notify(self, sender: object, event: str) -> None:
        pass

class SmartRoomMediator(Mediator):
    def __init__(self, table, chair_lst):
        self.table = table
        self.chair_lst = chair_lst
        self.table.mediator = self
        for chair in self.chair_lst:
            chair.mediator = self

    def notify(self, sender, event):
        if sender == self.table:
            if event == "work":
                for chair in self.chair_lst:
                    chair.work()
            elif event == 'rest':
                for chair in self.chair_lst:
                    chair.rest()

def client():
    table = SmartTable()
    chair_lst = []
    for i in range(4):
        chair_lst.append(SmartChair(i))
    
    smart_room = SmartRoomMediator(table, chair_lst)
    
    table.work()
    print("*"*30)
    table.rest()

if __name__ == "__main__":
    client()
                    